{{template "header" .}}
<title>文章 - 我的博客文章</title>
</head>
<body>
<div class="navbar navbar-default navbar-static-top bs-docs-nav">
    <div class="container">
    {{template "navbar" .}}
    </div>
</div>

<div class="container">

    <div class="form-group">
        <h1 class="col-sm-10">文章列表</h1>
        <div class="col-sm-2">
            <a href="/topic/add" class="btn btn-default form-control">添加文章</a>
        </div>
    </div>

    <!-- Table -->
    <table class="table">
        <thead>
        <th>#</th>
        <th>名字</th>
        <th>内容</th>
        <th>浏览数</th>
        <th>回复数</th>
        <th>添加时间</th>
        <th>操作</th>
        </thead>
        <tbody>
        {{range .topicList}}
        <tr>
            <td>{{.Id}}</td>
            <td>{{.Title}}</td>
            <td>{{.Content}}</td>
            <td>{{.Views}}</td>
            <td>{{.ReplyCount}}</td>
            <td>{{.Created}}</td>
            <td><a onclick="delCate(this)" data-id="{{.Id}}">删除</a></td>
        </tr>
        {{end}}
        </tbody>
    </table>

</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
    function delCate(el) {
        $.post("/category", {"id": $(el).data('id'), "type": 'del'},
                function (msg) {
                    alert(msg)
                    window.location.reload()
                });
    }
</script>
</html>